home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / tvicon.exe / ICONS.PAS < prev   
Pascal/Delphi Source File  |  1993-03-28  |  1KB  |  65 lines

  1. Program IconTest;
  2.  
  3. {  This simple program demonstrates the use of TIcons  }
  4.  
  5. Uses
  6.   App,
  7.   CRT,
  8.   Icon,
  9.   Objects,
  10.   Views;
  11.  
  12. Type
  13.   MyApp = Object (TApplication)
  14.     Constructor Init;
  15.   end;
  16.  
  17. { override the DoubleCLick method to demonstrate its use. }
  18. { this example just beeps when the icon is double-clicked }
  19.  
  20.   PTestIcon     = ^TTestIcon;
  21.   TTestIcon     = Object (TIcon)
  22.     Procedure DoubleClick;
  23.       virtual;
  24.   end;
  25.  
  26. Procedure TTestIcon.DoubleClick;
  27. begin
  28.   Sound(5000);
  29.   delay(50);
  30.   NoSound;
  31. end;
  32.  
  33.  
  34. Constructor MyApp.Init;
  35. Var
  36.   R : TRect;
  37.   i : integer;
  38. begin
  39.   Inherited Init;
  40.   { insert some icons into the *Application* in random locations }
  41.  
  42.   for i := 1 to 5 do
  43.   begin
  44.     R.Assign(1,1,9,2);
  45.     R.Move(Random(70),Random(20));
  46.     Insert(New(PTestIcon,Init(R,'~Icon~ ' + char(i+$30))));
  47.   end;
  48.  
  49.   { put some normal windows on the Desktop to show how they interact
  50.     with icons }
  51.  
  52.   R.Assign(5,5,35,12);
  53.   InsertWindow(New(PWindow,Init(R,'Normal Window',1)));
  54.   R.Move(1,1);
  55.   InsertWindow(New(PWindow,Init(R,'Normal Window',2)));
  56. end;
  57.  
  58. Var
  59.   TestApp : MyApp;
  60.  
  61. BEGIN
  62.   TestApp.Init;
  63.   TestApp.Run;
  64.   TestApp.Done;
  65. END.